<%--

    Copyright 2011 Aaron Zeckoski
    This file is part of Maven Exercise 8.

    Maven Exercise 8 is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Maven Exercise 8 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Maven Exercise 8.  If not, see <http://www.gnu.org/licenses/>.

--%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.io.IOException"%>
<%@page import="java.util.Properties"%>
<%@page import="org.az.Sample"%>
<%@page import="org.joda.time.DateTime"%>
<%@page import="java.io.InputStream"%>
<%@page import="org.apache.commons.io.IOUtils"%>
<%
Properties props = new Properties();
try {
    InputStream versionsInputStream = this.getClass().getClassLoader().getResourceAsStream("data.properties");
    props.load(versionsInputStream);
    versionsInputStream.close();
} catch (Exception e) {
    // no versions could be loaded so log the warning
    out.print("Unable to load properties: "+e);
}

String id = Sample.storeComment();
String sample = Sample.trimLower("      This IS a SAMple  ");
%>
<html>
<body>
<h2>Hello World!</h2>
<h3><%= new DateTime().toString() %></h3>
<h3>Stored item in DB: <%= id %></h3>
<h4>Properties:</h4>
<div>
<% 
int i = 0;
for (Entry<Object, Object> prop : props.entrySet()) {
    i++;
%>
<div><%= i %>) <%= prop.getKey() %> : <%= prop.getValue() %></div>
<% } %>
</div>
<h5><%= sample %></h5>
</body>
</html>
